7. AR QR code 7.1. Overview 7.2. Create ARTag 7.2.1. install software package 7.2.2. Create AR QR code 7.3, ARTag identification 7.3.1. Start the identification instance 7.3.2. launch file analysis 7.3.3. ar_track_alvar node 7.3.4. View node graph 7.3.5. View tf tree 7.3.6. View output information
wiki: http://wiki.ros.org/ar_track_alvar/
Source code: https://github.com/ros-perception/ar_track_alvar.git
Feature pack location: ~/yahboomcar_ws/src/yahboomcar_visual
ARTag (AR tag, AR means "augmented reality") is a fiducial marker system, which can be understood as a reference for other objects. It looks similar to a two-dimensional code, but its encoding system and two-dimensional code are still very large. The difference is mostly used in camera calibration, robot positioning, augmented reality (AR) and other applications. One of the most important functions is to identify the pose relationship between the object and the camera. An ARTag can be attached to the object, or an ARTag label can be attached to a plane to calibrate the camera. After the camera recognizes the ARTag, the position and pose of the tag in the camera coordinates can be calculated.
ar_track_alvar has 4 main functions:
Alvar is newer and more advanced than ARToolkit, which has been the basis for several other ROS AR tagging packages. Alvar features adaptive thresholding to handle various lighting conditions, optical flow-based tracking for more stable pose estimation, and an improved label recognition method that does not slow down significantly as the number of labels increases.
sudo apt install ros-melodic-ar-track-alvar
ar_track_alvar is an open source marker library that provides examples of pr2+kinect. The first use case of this package is to recognize and track the pose of (potentially) multiple AR tags, each of which is considered individually.
xxxxxxxxxx
rosrun ar_track_alvar createMarker
You can enter [ID] and location information here, and enter [-1] to end. One or more can be generated, and the layout can be designed by yourself.
Command+parameters directly generate digital pictures; e.g.
xxxxxxxxxx
rosrun ar_track_alvar createMarker 11
rosrun ar_track_alvar createMarker -s 5 33
11: The number is the QR code of 11. -s: Specifies the image size. 5: 5x5 picture. 33: The number is the QR code of 33.
Note: When starting the camera, you need to load the camera calibration file, otherwise it will not be recognized.
xxxxxxxxxx
roslaunch yahboomcar_visual ar_track.launch open_rviz:=true
In rviz, you need to set the corresponding camera topic name.
xxxxxxxxxx
< launch >
<!-- Set camDevice parameters, the default is USBCam -->
< arg name = "open_rviz" default = "true" />
< arg name = "marker_size" default = "5.0" />
< arg name = "max_new_marker_error" default = "0.08" />
< arg name = "max_track_error" default = "0.2" />
<!-- Set camera image topic, camera internal reference topic, camera frame -->
< arg name = "cam_image_topic" default = "/usb_cam/image_raw" />
< arg name = "cam_info_topic" default = "/usb_cam/camera_info" />
< arg name = "output_frame" default = "/usb_cam" />
<!-- start camera node -->
< include file = "$(find usb_cam)/launch/usb_cam-test.launch" />
<!-- Set the correspondence between the camera coordinate system and the world coordinate system-->
< node pkg = "tf" type = "static_transform_publisher" name = "world_to_cam" args = "0 0 0.5 0 1.57 0 world usb_cam 10" />
<!-- Start AR recognition node-->
< node name = "ar_track_alvar" pkg = "ar_track_alvar" type = "individualMarkersNoKinect" respawn = "false" output = "screen" >
< param name = "marker_size" type = "double" value = "$(arg marker_size)" />
< param name = "max_new_marker_error" type = "double" value = "$(arg max_new_marker_error)" />
< param name = "max_track_error" type = "double" value = "$(arg max_track_error)" />
< param name = "output_frame" type = "string" value = "$(arg output_frame)" />
< remap from = "camera_image" to = "$(arg cam_image_topic)" />
< remap from = "camera_info" to = "$(arg cam_info_topic)" />
</ node >
<!-- start rviz -->
< node pkg = "rviz" type = "rviz" name = "rviz" args = "-d $(find yahboomcar_visual)/rviz/ar_track.rviz" if = "$(arg open_rviz)" />
</ launch >
Node parameters:
topic name | type of data |
---|---|
/camera_info | ( sensor_msgs/CameraInfo ) |
/image_raw | ( sensor_msgs/Image ) |
topic name | type of data |
---|---|
/visualization_marker | ( visualization_msgs/Marker ) |
/ar_pose_marker | ( ar_track_alvar/AlvarMarkers ) |
A single QR code: camera coordinate system → AR tag coordinate system
Multiple QR Codes: Provides a transformation from the camera coordinate system to each AR marker coordinate system (named ar_marker_x), where x is the marker's ID number.
xxxxxxxxxx
rqt_graph
xxxxxxxxxx
rosrun rqt_tf_tree rqt_tf_tree
Through rviz, we can intuitively see the relative position of the QR code and the camera. The camera and world coordinate system are set by themselves.
xxxxxxxxxx
rostopic echo / ar_pose_marker
The display is as follows:
xxxxxxxxxx
header:
seq: 0
stamp:
secs: 1630584915
nsecs: 196221070
frame_id: "/usb_cam"
id: 3
confidence: 0
pose:
header:
seq: 0
stamp:
secs: 0
nsecs: 0
frame_id: ''
pose:
position:
x: 0.0249847882514
y: 0.0290736736336
with: 0.218054183012
orientation:
x: 0.682039034537
y: 0.681265739969
with: -0.156112715404
in: 0.215240718735